import { MemberAddressItem } from '@/apis/address'
import { UserAddress } from '@/apis/order'
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useAddressStore = defineStore(
  'address',
  () => {
    // 选中收货地址
    const selectedAddress = ref({} as MemberAddressItem)

    // 修改收货地址
    const changeSelectedAddress = (address: MemberAddressItem) => {
      selectedAddress.value = address
    }


    return {
      selectedAddress,
      changeSelectedAddress,
    }
  },
  {
    persist: {
      storage: {
        setItem(key, value) {
          uni.setStorageSync(key, value)
        },
        getItem(key) {
          return uni.getStorageSync(key)
        },
      },
    },
  },
)
